const Generator = require('yeoman-generator')
module.exports = class extends Generator {
    prompting() {
        return this.prompt([
            {
                type: 'input',
                name: 'name',
                message: 'Project name?',
                default: 'zxy-app'
            }
        ])
        .then(answers => {
            this.answers = answers
        })
    }
    writing(){
        const templates = [
            '.editorconfig',
            '.gitignore',
            '.npmrc',
            '.travis.yml',
            'gulpfile.js',
            'LICENSE',
            'package.json',
            'README.md',
            'src/about.html',
            'src/index.html',
            'public/favicon.ico'
        ]

        templates.forEach(item => {
            // item => 每个文件路径
            this.fs.copyTpl(
                this.templatePath(item),
                this.destinationPath(item),
                this.answers
            )
        })
    }
}